package com.leetcode.LC;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;

public class LC893 {
    public int numSpecialEquivGroups(String[] A) {
        HashSet<String> set = new HashSet<>();
        for (String s : A) {
            ArrayList<Character> odd = new ArrayList<>();
            ArrayList<Character> even = new ArrayList<>();

            for (int i = 0; i < s.length(); i++) {
                if (i%2==0){
                    odd.add(s.charAt(i));
                }else {
                    even.add(s.charAt(i));
                }
            }

            Collections.sort(odd);
            Collections.sort(even);

            StringBuilder builder = new StringBuilder();
            for (Character character : odd) {
                builder.append(character);
            }
            for (Character character : even) {
                builder.append(character);
            }

            set.add(builder.toString());

        }

        return set.size();
    }


}
